import { ConfigEnv, defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import requireTransform from 'vite-plugin-require-transform'


const alias: Record<string, string> = {
	'@': path.join(__dirname, './src') ,
	'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js',
};

// https://vitejs.dev/config/
export default defineConfig((mode: ConfigEnv)=>{
	const env = loadEnv(mode.mode, process.cwd());
	return {
		plugins: [
			vue(),
			requireTransform({
				fileRegex: /.ts$|.tsx$|.tsx$/,
			}),
		],
		server: {
			host: '0.0.0.0',
			port: env.VITE_PORT as unknown as number,
			open: env.VITE_OPEN,
		},
		resolve: {
			alias
		},
	}
})
